package org.lanqiao.api.admin;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.common.Constants;
import org.lanqiao.common.JsonResult;
import org.lanqiao.common.JsonResultWriter;
import org.lanqiao.pojo.PageModel;
import org.lanqiao.pojo.UserPOJO;
import org.lanqiao.service.AdminServiceImpl;
import org.lanqiao.service.OrderServiceImpl;

/**
 * 修改用户信息
 * Servlet implementation class AmendUserServlet
 */
@WebServlet("/api/admin/AmendUserServlet")
public class AmendUserServlet extends HttpServlet {
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		
			String name=request.getParameter("Username");
			String userId=request.getParameter("UserId");
			String password=request.getParameter("Password");
			String sex=request.getParameter("Sex");		
			String age=request.getParameter("Age");
			String address=request.getParameter("Address");
			
			UserPOJO user=new UserPOJO();
			user.setUserId(userId);
			user.setUserName(name);
			user.setPassword(password);
			user.setSex(sex);
			user.setAge(age);
			user.setAddres(address);
			/**
			 * 调用修改用户方法
			 */
			AdminServiceImpl abc=new AdminServiceImpl();
			JsonResult result=null;
			try {
				int model=abc.amend(user);
				if(model>0){
					result=new JsonResult("修改成功",Constants.STATUS_SUCCESS);
				}else {
					result=new JsonResult("修改错误",Constants.STATUS_UNFOUND);
				}
			} catch (Exception e) {
				result=new JsonResult("修改异常",Constants.STATUS_FAILURE);
			}
			JsonResultWriter.writer(response, result);;
	}

}
